package org.game.module.event.listener;

import org.constant.EventConditionType;
import org.constant.EventType;
import org.game.db.bean.MonthCard;
import org.game.db.bean.Player;
import org.game.plugin.event.GameEvent;
import org.game.plugin.event.GameEventListener;
import org.game.plugin.event.GameEventStack;
import org.game.plugin.event.GameEventType;

/**
 * 月卡事件监听器
 * Created by fxf on 2018-2-5.
 */
@GameEventType(EventType.MONTH_CARD)
public class MonthCardEventListener implements GameEventListener {
    @Override
    public void onEvent(GameEvent event) {
        GameEventStack eventStack = event.peek();
        switch (eventStack.getConditionType()){
            case EventConditionType.GAIN_MONTH_CARD_ITEM:{
                if (checkTriggerType(event.getIn(),EventConditionType.GAIN_MONTH_CARD_ITEM)){
                    eventStack.changeProgress(1);
                }
            }
        }
    }

    @Override
    public void initEventCondition(Player player, GameEventStack eventStack) {
        if (eventStack.getConditionType() == EventConditionType.GAIN_MONTH_CARD_ITEM){
            MonthCard mc = player.getMonthCardsFkPlayerId();
            if (mc != null){
                eventStack.setProgress(0);
            }
        }
    }
}
